/**
 * @file      xtime.h
 * @copyright Copyright (c) 2020, ZCW Co., Ltd. All Rights Reserved.
 * @brief     brief
 * @author    caiwang213@qq.com
 * @date      2020-05-20 19:19:37
 *
 * @note
 *  xtime.h defines
 */
#ifndef __XTIME_H__
#define __XTIME_H__
#include <stdint.h>
#include <string>
using namespace std;

#ifndef DATETIME_MACRO
#define DATETIME_MACRO
typedef struct
{
    int            year;
    int            month;
    int            day;
    int            hour;
    int            minute;
    int            second;
} datetime_s;
#endif

namespace log4x
{
class time
{
public:
    static uint32_t    now_sec();
    static uint64_t    now_msec();
    static uint64_t    now_usec();
    static string      now_strf(const char* fmt = NULL);
    static string      now_strfmsec();

    static string      strftime(time_t sec = 0, const char* fmt = NULL);
    static string      strftime(datetime_s& d, const char* fmt = NULL);

    static int         strptime(const string& s, struct tm& t, const char* fmt = NULL);
    static time_t      strptime(const string& s, const char* fmt = NULL);
    static int         strptime(const string& s, datetime_s& d, const char* fmt = NULL);
};
}
#endif
